package cn.yqn.feigen;

import cn.yqn.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @BelongsProject: springcloudnetflix-parent
 * @BelongsPackage: cn.itsource.feignclient
 * @Author: Director
 * @CreateTime: 2022-07-31  02:48
 * @Description: UserFeign的熔断工厂类
 * @Version: 1.0
 */
@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {

    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User getById(Long id) {
                return new User(-1L, "触发熔断", "服务不可用，请稍后重试！");
            }
        };
    }
}